#include <stdio.h>

#define BASE (5L)


int main(int argc, const char ** argv)
{
	long orig_num = 0;
	unsigned long num = 0;
	unsigned long power = 1;
	long exp = 0;

	/*
	 * get input from user and validate
	 */
	printf("Enter number: ");
	scanf("%ld", &orig_num);
	if (orig_num < 1) {
		printf("Error! The number must be >= 1\n");
		return -1;
	}
	num = orig_num;

	/*
	 * calculate all the powers of `BASE` that are smaller 
	 * or equal to `num`. this way we take care of the 
	 * special case (num = 1) automagically. 
	 * 
	 * the only drawback is overflowing `power`, so we declared 
	 * it as `unsigned long`
	 */
	while (power < num) {
		power *= BASE;
		exp += 1;
	}

	/*
	 * if `power` is equal to `num`, `num` is a power of `BASE`
	 * otherwise, it's not.
	 */
	if (power == num) {
		printf("%ld is a power of %ld, exponent = %ld\n", num, BASE, exp);
	}
	else {
		printf("%ld is not a power of %ld\n", num, BASE);
	}

	/* 
	 * great success 
	 */
	return 0;
}